package com.ftg.rbac.mapper;

import com.ftg.rbac.entity.Dept;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * 部门sql处理
 *
 * @author kangjx
 * @version 1.0
 * @date 2023/3/16 上午9:08
 */
public interface DeptMapper {

    /**
     * 为了完成用户删除时，对部门负责人设null操作
     * @param userid
     * @return
     */
    @Update("update dept set uid = null where uid = #{userid}")
    int setNullForDeptName(@Param("userid") int userid);

    @Select("select count(uid) from dept where uid = #{userid}")
    int findDeptName(@Param("userid") int userid);

    @Select("select * from dept")
    List<Dept> list();

    @Select("select count(did) from dept where did = #{did}")
    int findNumByDid(@Param("did") Integer did);

}
